<?php
/**
 * P�gina principal do sistema, cont�m todos os menus da aplica��o.
*/
if( !function_exists('__autoload') )
{
    function __autoload($class_name) {
    require_once $class_name . '.php';
    }
}

SAEO::ValidarAcesso( array() );

?>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SAEO - Sistema de Acompanhamento de Execu&ccedil;&atilde;o Or&ccedil;ament&aacute;ria - IFAL</title>
<link rel='stylesheet' href='templates/estilos.css'>
</head>
<body class='body'>
	<table width='779' border='0' cellspacing='0' cellpadding='0' align='center'>
		<tr>
    		<td height='30'><?php include 'Topo.php'; ?></td>
  		</tr>
  		<tr>
                <td><div class='titulosTabelas' style='width:779; height:20; background:url(templates/tabela.jpg)'>LISTA DE RATEIOS</div></td>
        </tr>
  		<tr>
    		<td bgcolor='#FFFFFF'>
    			<div style='margin-top: 100px; margin-bottom: 100px;'>
                                        
					<table id='dadosFornecedor' style="width: 650" border='0' cellpadding='0' align='center' bgcolor='#FFFFFF' class='detalhamento'>
						<thead class='detalhamento'>
						<tr>
							<th>Unidade</th>
							<th width="15%">Fonte</th>
							<th width="15%">Tipo de Despesa</th>
							<th>Valor Total</th>
							<th>Saldo</th>
						</tr>
						</thead>
						<tbody class='detalhamento' id='corpoPrograma'>
						<?php 
							$rateioDao = new Rateio();
							if($_GET['fonteId'] != 0 ){
								$rateios = $rateioDao->CarregarRateioPorFonte($_GET['fonteId']);
							}else if(isset($_GET['programaId'])){																
								$rateios = $rateioDao->CarregarRateioPorPrograma($_GET['programaId'],$_GET['tipoDespesa'] );
							}
								
							if(!$rateios){
						?>
							<tr>
								<td colspan="6" class="textoCentral">Nenhum Rateio encontrado</td>
							</tr>
						<?php 
							}
							foreach ($rateios as $rateio){
						?>
							<tr>
								<td ><?php echo $rateio->campus->nome; ?></td>
								<td align="center"><?php echo $rateio->fonte->fonteRecurso; ?></td>
								<td align="center"><?php echo (($rateio->tipoDespesa=="33")?"33 - Corrente":"44 - Capital"); ?></td>
								<td align="right">R$<?php echo number_format($rateio->valorTotal/100,2, ',', '.'); ?></td>
								<td align="right">R$<?php echo number_format($rateio->getSaldoRateio($rateio->fonte->id,$rateio->campus->id)/100,2, ',', '.'); ?></td>
									
							</tr>
						<?php 
							}
						?>
                        </tbody>
						
					</table>
			
				</div>
			</td>
  		</tr>
		<tfoot>
        	<tr><?php include 'rodapeCreditos.php'; ?></tr>
        </tfoot>
	</table>
</body>
</html>